package com.leezk.order.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.leezk.order.constant.CommonConstant;
import com.leezk.order.dto.ResultDTO;
import com.leezk.order.dto.TagMapperDto;
import com.leezk.order.entity.Orders;
import com.leezk.order.entity.TagMapper;
import com.leezk.order.service.ITagMapperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author leotong
 * @since 2022-03-16
 */
@RestController
@RequestMapping(CommonConstant.API_URI_VERSION_V1+"/tagMapper")
public class TagMapperController {
    @Autowired
    private ITagMapperService tagMapperService;

    @GetMapping("/getTagMappers")
    public ResultDTO<Page<TagMapperDto>> getTagMappers(int pageNum, int pageSize){
        Page<TagMapper> page=new Page<>(pageNum,pageSize);
        return ResultDTO.success(tagMapperService.getTagMappers(page));
    }


    @GetMapping("/addTagMappers")
    public ResultDTO<Boolean> addTagMappers(int did){
        TagMapper tagMapper=new TagMapper();
        tagMapper.setDid(did);
        return ResultDTO.success(tagMapperService.save(tagMapper));
    }

    @PostMapping("/updateTagMappers")
    public ResultDTO<Boolean> updateTagMappers(@RequestBody TagMapper tagMapper){
        return ResultDTO.success(tagMapperService.updateById(tagMapper));
    }
}
